package redis

import (
	"fmt"
	"github.com/go-redis/redis"
	"shop_srv/appconfig"
)

var Red *redis.Client

func ExampleNewClient() {
	app := appconfig.AppConf.RedisConfig
	addr := fmt.Sprintf("%s:%d", app.Host, app.Port)
	Red = redis.NewClient(&redis.Options{
		Addr:     addr,
		Password: app.Passwd, // no password set
		DB:       0,          // use default DB
	})

	pong, err := Red.Ping().Result()
	if err != nil {
		return
	}
	fmt.Println(pong, err)
	// Output: PONG <nil>
}
